package com.shan.design.proxy;

import java.util.Date;

/**
 * @author shanzheng <br/>
 * @date 9:40 2018/11/27.<br/>
 * Modified By <br/>
 */
public class Proxy implements Software {

    private RealSoftware realSoftware = new RealSoftware();

    public void beforeMethod() {
        System.out.println(new Date());
    }

    @Override
    public void method() {
        beforeMethod();
        try {
            realSoftware.method();
            successMethod();
        } catch (Exception e) {
            failMethod();
            e.printStackTrace();
        }

    }

    public void successMethod() {
        System.out.println("方法Method()调用成功");
    }

    public void failMethod() {
        System.out.println("方法Method()调用失败");
    }
}
